package com.pctx.bibasms.ronglian;

import java.util.HashMap;
import java.util.Set;


public class SDKTestSendTemplateSMS {

	public static String getCode(String mobile){
		HashMap<String, Object> result = null;

		CCPRestSDK restAPI = new CCPRestSDK();
		restAPI.init("app.cloopen.com", "8883");// 初始化服务器地址和端口，格式如下，服务器地址不需要写https://
		restAPI.setAccount("8a48b5514b003ad2014b069d6150049a", "569ed9065db84b6189505a5b4d7c5452");// 初始化主帐号和主帐号TOKEN
		restAPI.setAppId("8a216da86010e69001601659069d01bd");// 初始化应用ID
		int code = (int)((Math.random()*9+1)*100000);
		String ss[] = new String[] {code+"","10"};
		result = restAPI.sendTemplateSMS(mobile,"222193" ,ss);

		System.out.println("SDKTestSendTemplateSMS result=" + result);

		//异常统一处理
		if("000000".equals(result.get("statusCode"))){
			//正常返回输出data包体信息（map）
			HashMap<String,Object> data = (HashMap<String, Object>) result.get("data");
			Set<String> keySet = data.keySet();
			for(String key:keySet){
				Object object = data.get(key);
				System.out.println(key +" = "+object);
			}
		}else{
			//异常返回输出错误码和错误信息
			System.out.println("错误码=" + result.get("statusCode") +" 错误信息= "+result.get("statusMsg"));
		}

		return code+"";
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}

}
